/*
 * Copyright 2014 Alex Curran
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.espian.showcaseview.sample;

import com.github.amlcurran.showcaseview.OnShowcaseEventListener;
import com.github.amlcurran.showcaseview.ShowcaseView;

import ohos.multimodalinput.event.TouchEvent;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 监听多个引导层显示事件
 */
public class MultiEventListener implements OnShowcaseEventListener {
    private final List<OnShowcaseEventListener> listeners;

    public MultiEventListener(OnShowcaseEventListener... listeners) {
        this.listeners = new ArrayList<>();
        this.listeners.addAll(Arrays.asList(listeners));
    }

    @Override
    public void onShowcaseViewHide(ShowcaseView showcaseView) {
        for (OnShowcaseEventListener listener : listeners) {
            listener.onShowcaseViewHide(showcaseView);
        }
    }

    @Override
    public void onShowcaseViewDidHide(ShowcaseView showcaseView) {
        for (OnShowcaseEventListener listener : listeners) {
            listener.onShowcaseViewDidHide(showcaseView);
        }
    }

    @Override
    public void onShowcaseViewShow(ShowcaseView showcaseView) {
        for (OnShowcaseEventListener listener : listeners) {
            listener.onShowcaseViewShow(showcaseView);
        }
    }

    @Override
    public void onShowcaseViewTouchBlocked(TouchEvent motionEvent) {
        for (OnShowcaseEventListener listener : listeners) {
            listener.onShowcaseViewTouchBlocked(motionEvent);
        }
    }
}
